<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>vue中的样式绑定</title>
  <script src="./vue.js"></script>
  <style>
    .actived {color: red;}
  </style>
</head>

<body>
  <!-- :class="{}" class的对象绑定 -->
  <!-- <div id="app" @click = "handleClick" :class="{actived: isActived}"> -->
  <!-- <div id="app" @click="handleClick" :class="[actived, actTwo]"> -->
  <div id="app" @click="handleClick" :style="styleObj">
    hello word
  </div>
  <script>
    var vm = new Vue({
      el: '#app',
      data: {
        // isActived: false
        // actived: "",
        // actTwo
        styleObj: {
          color: "black"
        }
      },
      methods: {
        // handleClick: function() {
        //   this.isActived = !this.isActived;
        // }
        handleClick: function () {
          // if (this.actived === "actived") {
          //   this.actived = "";
          // } else {
          //   this.actived = "actived";
          // }
          // this.actived = this.actived === "actived" ? "" : "actived";
          this.styleObj.color = this.styleObj.color === "black" ? "red" : "black";
        }
      }
    })



  </script>
</body>

</html>